package org.zfes.snowier.cloud.zbss.layer.tc.biz.controller;

import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.model.Casereason;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.service.ICasereasonService;
@Controller 
@RequestMapping("/tcms/casereason")
public class CasereasonController extends BaseController {

	private String viewPathPrefix="/tcms";
	
	@Autowired
	private ICasereasonService casereasonService;
	
	@RequestMapping(value={"/",""}, method = RequestMethod.GET,produces = MediaType.TEXT_HTML_VALUE)
    public Object index(){
		return forward(viewPathPrefix,"casereason.html");
    }
	
	//@RequiresPermissions(value="casereason:loadCasereasonList",desc="案由列表")
    @RequestMapping(value="/loadCasereasonDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCasereasonDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  casereasonService.loadCasereasonDataSet(params);
	    return dataSet;
    }
	
//	@RequiresPermissions(value="casereason:addCasereason",desc="案由添加")
    @RequestMapping(value="/addCasereason", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object addCasereason(Casereason casereason){
		casereasonService.createCasereason(casereason);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="casereason:loadCasereason",desc="案由加载")
    @RequestMapping(value="/loadCasereason", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCasereason(Long id){
		Optional<Casereason> ops = casereasonService.loadCasereasonById(id);
		return ajaxQuery("casereason",ops);
    }
	
	//@RequiresPermissions(value="casereason:updateCasereason",desc="案由更新")
    @RequestMapping(value="/updateCasereason", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCasereason(Casereason casereason){
		casereasonService.updateCasereason(casereason);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="casereason:deletCasereason",desc="案由删除")
    @RequestMapping(value="/deletCasereason", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletCasereason(Long id){
		casereasonService.deletCasereason(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}